﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GatewayInspect.Common;
using System.Data.OracleClient;

namespace GatewayInspect.Modules
{
    public partial class BlacklistDeleteForm : Form
    {
        private string _id;

        public BlacklistDeleteForm()
        {
            InitializeComponent();
        }

        public BlacklistDeleteForm(string id, string truckNo, string driverId, string driverName)
            : this()
        {
            this._id = id;
            this.txtTruckNo.Text = truckNo;
            this.textDriverID.Text = driverId;
            this.textDriverName.Text = driverName;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string sReason = txtReason.Text;
            if (DeleteBlacklist())
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("删除失败，请与管理员联系！");
            }
        }

        private bool DeleteBlacklist()
        {
            string strSQL = "update T_TRUCK_BLACKLIST set ISDEL='1', DELREASON=:DELREASON, DELMAN=:DELMAN, DELTIME=:DELTIME WHERE ID=:ID"; ;
            int i = DataAccess.ExecuteNonQuery(strSQL, new OracleParameter(":ID", this._id),
                new OracleParameter(":DELREASON", txtReason.Text),
                new OracleParameter(":DELMAN", Session.CurrentUserName),
                new OracleParameter(":DELTIME", DateTime.Now));
            return i > 0;
        }
    }
}
